package com.lagou.service.impl;

import com.lagou.dao.AccountDao;
import com.lagou.service.AccountService;
import com.lagou.utils.TransactionManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("accountService")
public class AccountServiceImpl implements AccountService {

    @Autowired
    private AccountDao accountDao;
    /*
    * 转账方法 切入点 添加上事务控制的效果
    * */
    @Override
    public void transfer(String outUser, String inUser, Double money) {

            //调用了减钱方法
            accountDao.out(outUser,money);

            //int i=1/0;  //出现异常后 回滚事务 所以钱不会发生变化

            //调用了加钱方法
            accountDao.in(inUser,money);
    }

    @Override
    public void save() {
        System.out.println("save方法");
    }

    @Override
    public void update() {
        System.out.println("update方法");
    }

    @Override
    public void delete() {
        System.out.println("delete方法");
    }
}
